# coding=utf-8
# 保存下面代码为 "微信截图.pyw"，并把微信安装文件夹的 PrScrn.dll 文件拷贝到同一目录下
# !/usr/bin/env python
# -*- coding:utf-8 -*-

import ctypes
import os


# 截屏方法
def capture2():
    try:
        dll = ctypes.cdll.LoadLibrary('PrScrn.dll')
    except Exception:
        print("Dll load error!")
        try:
            # 如果dll加载失败，则换种方法使用，直接运行，如果还失败，退出
            res = os.system("Rundll32.exe PrScrn.dll, PrScrn")
            print res
        except Exception:
            return
    else:
        try:
            dll.CameraSubArea(0)
        except Exception:
            print("Sth wrong in capture!")
            return


def capture():
    try:
        dll = ctypes.cdll.LoadLibrary('PrScrn.dll')
    except Exception:
        print("Dll load error!")
        return
    else:
        try:
            dll.PrScrn(0)
        except Exception:
            print("Sth wrong in capture!")
            return


def main():
    capture2()


#    os.system("pause")

if __name__ == "__main__":
    main()
